home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / djgpp / contrib / pdcurs22 / src / private / pdcprint.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-01-26  |  2.8 KB  |  106 lines

  1. /*
  2. ***************************************************************************
  3. * This file comprises part of PDCurses. PDCurses is Public Domain software.
  4. * You may use this code for whatever purposes you desire. This software
  5. * is provided AS IS with NO WARRANTY whatsoever.
  6. * Should this software be used in another application, an acknowledgement
  7. * that PDCurses code is used would be appreciated, but is not mandatory.
  8. *
  9. * Any changes which you make to this software which may improve or enhance
  10. * it, should be forwarded to the current maintainer for the benefit of 
  11. * other users.
  12. *
  13. * The only restriction placed on this code is that no distribution of
  14. * modified PDCurses code be made under the PDCurses name, by anyone
  15. * other than the current maintainer.
  16. * See the file maintain.er for details of the current maintainer.
  17. ***************************************************************************
  18. */
  19. #define    CURSES_LIBRARY    1
  20. /*#define NEEDS_OS2       1*/
  21. #include <curses.h>
  22.  
  23. #ifdef PDCDEBUG
  24. char *rcsid_PDCprint  = "$Id$";
  25. #endif
  26.  
  27. #ifdef OS2
  28. #  if !defined (CURSES__32BIT__) && !defined(CSET2) && !defined(MSC) &&!defined(TC)
  29. #define INCL_DOS
  30. #include <bsedos.h>
  31. #endif
  32. char Printer[]="LPT1:";
  33. #endif
  34.  
  35.  
  36. /*man-start*********************************************************************
  37.  
  38.   PDC_print()    - Provides primitive access to the BIOS printer functions
  39.  
  40.   PDCurses Description:
  41.      This is a private PDCurses routine.
  42.  
  43.      Implements write/init/read printer services at the BIOS level.
  44.  
  45.      This provides the basic support that PDCurses needs to dump the
  46.      contents of windows or pads to the printer attached to the BIOS
  47.      printer port.
  48.  
  49.   PDCurses Return Value:
  50.      See the BIOS INT 0x17 specifications.
  51.  
  52.   PDCurses Errors:
  53.      See the BIOS INT 0x17 specifications.
  54.  
  55.   Portability:
  56.      PDCurses    int PDC_print( int cmd, int byte, int port );
  57.  
  58. **man-end**********************************************************************/
  59.  
  60. int    PDC_print(int cmd, int byte, int port)
  61. {
  62. #ifdef    OS2
  63. #  if !defined (CURSES__32BIT__) && !defined(CSET2) && !defined(TC)
  64.     HFILE Lpt;
  65.     USHORT Action=0;
  66.     USHORT NoWritten=0;
  67. #  endif
  68. #endif
  69.  
  70. #ifdef    DOS
  71.     int    status = 0;
  72. #endif
  73.  
  74. #ifdef PDCDEBUG
  75.     if (trace_on) PDC_debug("PDC_print() - called\n");
  76. #endif
  77.  
  78. #ifdef    FLEXOS
  79.     return( OK );
  80. #endif
  81.  
  82. #ifdef    DOS
  83.     regs.h.ah = (unsigned char)cmd;
  84.     regs.h.al = (unsigned char)byte;
  85. # ifdef WATCOMC
  86.     regs.w.dx = (unsigned int)port;
  87. # else
  88.     regs.x.dx = (unsigned int)port;
  89. # endif
  90.     int86(0x17, ®s, ®s);
  91.     status = regs.h.ah;
  92.     return (status);
  93. #endif
  94.  
  95. #ifdef    OS2
  96. #  if !defined (CURSES__32BIT__) && !defined(CSET2) && !defined(TC)
  97.     if (DosOpen((PSZ)Printer, &Lpt, &Action, 0,0,0,0,0) != 0)
  98.         return(ERR);
  99.     DosWrite(Lpt,&byte,1,&NoWritten);
  100.     DosClose(Lpt);
  101.     return(NoWritten == 1);
  102. #  endif
  103. #endif
  104. }
  105.